#include <stdint.h>
#include <stddef.h>
#include "iot_watchdog.h"
#include "los_task.h"
#include "los_compiler.h"
#include "cmsis_os2.h"
#include "ohos_init.h"
#include "ohos_types.h"

void feed_dog(uint32_t arg){
    IoTWatchDogKick();
}

void wdg_entry()
{
    uint32_t ret, st_id;
    printf("----- watchdog test -----\n");
    IoTWatchDogEnable();
    IoTWatchDogDisable();
    LL_uDelay(3000*1000);
    IoTWatchDogKick();
    IoTWatchDogDisable();
}

void wdg_task()
{
    UINT32 uwRet = -1;
    UINT32 taskID = 0;
    TSK_INIT_PARAM_S stTask = {0};
    stTask.pfnTaskEntry = (TSK_ENTRY_FUNC)wdg_entry;
    stTask.uwStackSize = 0x1000;
    stTask.pcName = "watchdog task";
    stTask.usTaskPrio = 10;
    uwRet = LOS_TaskCreate(&taskID, &stTask);
    if (uwRet != LOS_OK) {
        printf("Task fs create failed\n");
    }
}